package com.house365.core.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author py
 * @date 2012-6-12
 * @comment
 */
public class Group<R,T> implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3015999252656391616L;
	protected List<T> subs;
	protected R r; 
	public Group(R r) {
		this.r =r;
		subs = new ArrayList<T>();
	}
	 
	public Group(R r,List<T> subs){
		this.r = r;
		this.subs = subs;
	}
	public R getGroup(){
		return r;
	}
	public List<T> getSubs() {
		if (subs == null) {
			subs = new ArrayList<T>();
		}
		return subs;
	}

	public void clear() {
		getSubs().clear();
	}

	public void addSubs(List<? extends T> tlist) {
		getSubs().addAll(tlist);
	}

	public int getSubsCount() {
		return subs == null ? 0 : subs.size();
	}

	public T getSub(int i) {
		return this.subs.get(i);
	}


	public T removeSub(int i) {
		return subs.remove(i);
	}

	public void addSub(T t) {
		this.subs.add(t);
	}
}
